//
//  ChatRoomTableViewCell.m
//  MyYiJianKangApp
//
//  Created by 张国文 on 16/4/6.
//  Copyright © 2016年 hangzhouyijiyin. All rights reserved.
//

#import "ChatRoomTableViewCell.h"

@implementation ChatRoomTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addMySubview];
    }
    return self;
}

// 布局
- (void)addMySubview
{
    self.chatRoomImageV = [[UIImageView alloc] initWithFrame:CGRectMake(13 * kAdjustParamater, 10 * kAdjustParamater, 40  * kAdjustParamater, 40 * kAdjustParamater)];
    self.chatRoomImageV.layer.cornerRadius = self.chatRoomImageV.width / 2;
    self.chatRoomImageV.layer.masksToBounds = YES;
    self.chatRoomImageV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2];
    [self.contentView addSubview:_chatRoomImageV];
    
    self.chatRoomName = [[UILabel alloc] initWithFrame:CGRectMake(self.chatRoomImageV.right + 12 * kAdjustParamater, self.chatRoomImageV.top + 4 * kAdjustParamater, 200 * kAdjustParamater, 15 * kAdjustParamater)];
 //   self.chatRoomName.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    self.chatRoomName.textColor = [UIColor blackColor];
    self.chatRoomName.textAlignment = NSTextAlignmentLeft;
    self.chatRoomName.font = [UIFont systemFontOfSize:k16Big];
    [self.contentView addSubview:_chatRoomName];
    
    self.chatRoomIntroduce = [[UILabel alloc] initWithFrame:CGRectMake(self.chatRoomImageV.right + 12 * kAdjustParamater, self.chatRoomName.bottom + 5 * kAdjustParamater, 200 * kAdjustParamater, 14 * kAdjustParamater)];
    self.chatRoomIntroduce.textColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
  //  self.chatRoomIntroduce.backgroundColor = [UIColor cyanColor];
    self.chatRoomIntroduce.textAlignment = NSTextAlignmentLeft;
    self.chatRoomIntroduce.font = [UIFont systemFontOfSize:k14Big];
    [self.contentView addSubview:_chatRoomIntroduce];
    
    self.joinChatRoomButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.joinChatRoomButton.frame = CGRectMake(kScreenWidth - 100 * kAdjustParamater, 20 * kAdjustParamater, 85 * kAdjustParamater, 20 * kAdjustParamater);
    self.joinChatRoomButton.layer.borderColor = [[[UIColor blackColor] colorWithAlphaComponent:0.2] CGColor];
    self.joinChatRoomButton.layer.borderWidth = 1 * kAdjustParamater;
    self.joinChatRoomButton.layer.cornerRadius = 3 * kAdjustParamater;
    [self.joinChatRoomButton setTitle:@"加入聊天室" forState:UIControlStateNormal];
    [self.joinChatRoomButton setTitleColor:[UIColor colorWithRed:233 / 255.0 green:138 / 255.0 blue:30 / 255.0 alpha:1] forState:UIControlStateNormal];
    self.joinChatRoomButton.titleLabel.font = [UIFont systemFontOfSize:k14Big];
    [self.contentView addSubview:_joinChatRoomButton];
    
}

- (void)setModel:(ChatRoomModel *)model
{
    self.chatRoomName.text = model.name;
    self.chatRoomIntroduce.text = model.introduce;
}

@end
